package com.example.glide

import android.animation.ObjectAnimator
import android.os.Bundle
import android.view.View
import android.view.animation.LinearInterpolator
import android.widget.ImageView
import androidx.appcompat.app.AppCompatActivity
import com.bumptech.glide.Glide


class MainActivity : AppCompatActivity() {

    private val imageUrl =
        "https://i.loli.net/2020/03/25/nOhLrpRmF3evtGu.jpg"

    private lateinit var imageView: ImageView


    private lateinit var rotateAnimation: ObjectAnimator

    override fun onCreate(savedInstanceState: Bundle?) {

        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        imageView = findViewById(R.id.avatar)

        rotateAnimation = ObjectAnimator.ofFloat(imageView, View.ROTATION, 0f, 360f)
        rotateAnimation.duration = 60000
        rotateAnimation.repeatCount = -1
        rotateAnimation.interpolator = LinearInterpolator()

        loadImage()
        rotateAnimation.start()
    }

    private fun loadImage() {
        Glide.with(this).load(imageUrl).circleCrop().into(imageView)
    }
}

